package com.thz.system.utlis;

import com.thz.common.core.enums.ResultCode;
import com.thz.common.core.result.Result;
import com.thz.exception.ApplicationException;

import java.time.LocalDateTime;

/**
 * @Description
 * @Author thz
 * @Date 2025/3/24
 */
public class ExamUtils {

    public static void  checkExamSaveParams(LocalDateTime startTime,LocalDateTime endTime){
        if (startTime.isBefore(LocalDateTime.now())){
            // 抛出异常
            throw new ApplicationException(Result.failed(ResultCode.EXAM_START_TIME_BEFORE_CURRENT_TIME));
        }
        if (startTime.isAfter(endTime)){
            // 抛出异常
            throw new ApplicationException(Result.failed(ResultCode.EXAM_START_TIME_AFTER_END_TIME));
        }
    }


    public static void  checkHomeworkSaveParams(LocalDateTime startTime,LocalDateTime endTime){
        if (startTime.isBefore(LocalDateTime.now())){
            // 抛出异常
            throw new ApplicationException(Result.failed(ResultCode.HOMEWORK_START_TIME_BEFORE_CURRENT_TIME));
        }
        if (startTime.isAfter(endTime)){
            // 抛出异常
            throw new ApplicationException(Result.failed(ResultCode.HOMEWORK_START_TIME_AFTER_END_TIME));
        }
    }

}
